var config = require('../../config/config.js')
Page({
  /**
   * 页面的初始数据
   */
  data: {
    mid: "",
    nickname: "",
    avatarurl: '',
    info: {},
     borrow_bucket_num:0,
     cash_bucket_num:0,
     self_bucket_num:0,
     total_bucket_num:0,
     total_waterbill_num:0,
     deposit:0,
    address: []
  },
  onOrder: function () {
    wx.navigateTo({
      url: "order/order",
    })
  },
  shuipiao: function () {
    wx.navigateTo({
      url: "shuipiao/shuipiao",
    })
  },
  cash: function () {
    wx.navigateTo({
      url: "cash/cash",
    })
  },
  shuitong: function () {
    var borrow_bucket_num = this.data.borrow_bucket_num;
    var cash_bucket_num = this.data.cash_bucket_num;
    var self_bucket_num = this.data.self_bucket_num;
    var total_bucket_num = this.data.total_bucket_num;
    wx.navigateTo({
      url: "shuitong/shuitong?borrow_bucket_num=" + borrow_bucket_num + "&cash_bucket_num=" + cash_bucket_num + "&self_bucket_num=" + self_bucket_num + "&total_bucket_num=" + total_bucket_num,
    })
  },
  onAdress: function (e) {
    var reback = 1;
    wx.navigateTo({
      url: "address/address?reback=" + reback,
    })
  },
  moveTo: function (e) {
    wx.navigateTo({
      url: "moveTo/moveTo",
    })
  },
  contanterTo: function (e) {
    wx.navigateTo({
      url: "contanter/contanter",
    })
  },
  introduceTo: function (e) {
    wx.navigateTo({
      url: "introduce/introduce",
    })
  },
  skillTo: function (e) {
    wx.navigateTo({
      url: "skill/skill",
    })
  },
  ClaimingTo: function (e) {
    wx.navigateTo({
      url: "Claiming/Claiming",
    })
  },
  personnalTo: function (e) {
    wx.navigateTo({
      url: "../personal/personal",
    })
  },
  getInfoUrl: function (e) {
    var that = this;
    var member_info = (wx.getStorageSync('member_info'));
    wx.request({
      url: config.member_info,
      data: {
        mid: member_info.mid,
        aid: member_info.aid,
        sid: member_info.sid,
      },
      method: 'GET',
      success: function (res) {
        that.setData({
          info: res.data.data.info,
          borrow_bucket_num: res.data.data.info.borrow_bucket_num,
          cash_bucket_num: res.data.data.info.cash_bucket_num,
          self_bucket_num: res.data.data.info.self_bucket_num,
          total_bucket_num: res.data.data.info.total_bucket_num,
        })
      },
      fail: function () {
      },
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    if (!wx.getStorageSync('member_info')) {
      wx.switchTab({
        url: '../takeWater/takeWater',
      })
      return
    }
    var member_info = (wx.getStorageSync('member_info'));
    this.setData({
      mid: member_info.mid,
      nickname: member_info.nickname,
      avatarurl: member_info.avatarurl
    })
    
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.getInfoUrl()
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})